<?php
session_start();

if (isset($_SESSION['ID'])) {
    $ID_LOGADO = $_SESSION['ID'];
    $PERMISSAO = $_SESSION['PERMISSAO'];
} else {
    echo "<script type='text/javascript'>";
    echo "window.location = 'index.php';";
    echo "</script>";
}
if ($PERMISSAO > 1) {
    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <script type="text/javascript">
                function validarSenha(form) {
                    senha = document.formulario.SENHA1.value
                    senhaRepetida = document.formulario.SENHA2.value
                    if (senha != senhaRepetida) {
                        alert("Repita a senha corretamente");
                        document.formulario.SENHA2.focus();
                        return false;
                    }
                }
                function voltar() {
                    window.location = 'visualizar_servidor.php';
                }
                
            </script>
            <link href="Styles/CSS.css" rel="stylesheet" type="text/css"/>
            <meta charset="UTF-8">
            <title>AGE - Cadastro de Servidor</title>
        </head>
        <body style="background-color: #9cea70"  onload="startTime()">
            <?php include("./cabecalho.html") ?>
            <table id="SITE">
                <tr>
                    <td id="MENU" valign="top">
                        <?php include("./menuLateral.php") ?>
                    </td>
                    <td id="CONTEUDO">
                        <form name="formulario" onsubmit="return validarSenha(this);" action="operacoesPHP/registraServidor.php" method="POST"  enctype="multipart/form-data">
                            <h1> Cadastro de Servidor </h1>
                            <table width="400" border="0">
                                <tr>
                                    <td>Foto Perfil</td>
                                    <td><input type="file" name="arquivo" id="Arquivo"></td>
                                </tr>
                                <tr>
                                    <td width="150px">Nome*:</td>
                                    <td><input type="text" name="NOME" required></td>
                                </tr>
                                <tr>
                                    <td>Nascimento*:</td>
                                    <td><input type="date" name="DATA_NASCIMENTO" required></td>
                                </tr>
                                <tr>
                                    <td>E-mail*:</td>
                                    <td><input type="email" name="EMAIL" required></td>
                                </tr>
                                <tr>
                                    <td>Tipo Servidor*:</td>
                                    <td><input type="text" name="TIPO_SERVIDOR" required></td>
                                </tr>
                                <tr>
                                    <td>Facebook(Link):</td>
                                    <td><input type="url" name="FACEBOOK"></td>
                                </tr>
                                <tr>
                                    <td>Lattes(Link):</td>
                                    <td><input type="url" name="LATTES"></td>
                                </tr>
                                <tr>
                                    <td>Login*:</td>
                                    <td><input type="text" name="LOGIN" required></td>
                                </tr>
                                <tr>
                                    <td>Senha*:</td>
                                    <td><input type="password" name="SENHA1" required></td>
                                </tr>
                                <tr>
                                    <td>Senha Novamente*:</td>
                                    <td><input type="password" name="SENHA2" required></td>
                                </tr>
                                <tr>
                                    <td><input type="submit" value="Cadastrar"></td>
                                    <td><input type="button" value="Voltar" onclick="return voltar()"></td>
                                </tr>
                            </table>
                        </form>
                    </td>
                </tr>
            </table>
        </body>
    </html>
    <?php
} else {
    echo "<script type='text/javascript'>";
    echo "window.location = 'Novidades.php';";
    echo "</script>";
}
?>